package com.stbu.bean;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class JsonController {
    @ResponseBody
    @RequestMapping("/testJson")
    public String jsonTest() throws JsonProcessingException {
        User user = new User();
        user.setId(33);
        user.setUsername("202303");
        user.setPassword("030303");
        ObjectMapper json = new ObjectMapper();
        return json.writeValueAsString(user);
    }
}
